<?php
include ("global.php");

if($configarray[40]){
 $links=" > User controls";
 $pagetitle=" - User controls";
 include("header.php");
 tableheader1();
 print "<tr><td class=\"tablecell1\"><span class=\"textlarge\">";
 print "<b>Board closed:</b><br>$configarray[40]";
 print "</span></td></tr></table>";
}else{

if(!$user){$user=$useridarray[$navboardlogin];}

$user=(float) $user;
$useridarray[$navboardlogin]=(float) $useridarray[$navboardlogin];

//not logged in || not own profile and not admin || not own profile
if(($user!==$useridarray[$navboardlogin])&&($userloggedinarray[15]!=="administrator")||$login!==1){
 $links=" > Profile > Options";
 $pagetitle=" - Profile - Options";

 include("header.php");
 include("user_header.php");

 echo template('notice',array('notice'=>'You do not have access to the users controls'));

}else{

$userarray=getdata("$configarray[1]/$user/main.php");

$links=" > Profile > Options > $userarray[0]";
$pagetitle=" - Profile - Options - $userarray[0]";

include("header.php");
include("user_header.php");

 //update account
 if($update==1){

  writedata("$configarray[1]/$user/options.php",$turnoffautocheckpms,0);
  writedata("$configarray[1]/$user/options.php",$turnofficonguide,1);
  writedata("$configarray[1]/$user/options.php",$turnoffpoststats,2);
  if($onlinelistname=="on"){
   $onlinearray=getdata("$configarray[1]/online.php");
   for($n=0;$n<count($onlinearray);$n++){
    if($onlinearray[$n]==$user){
	 deletedata("$configarray[1]/online.php",$n);
	}
   }
  }
  writedata("$configarray[1]/$user/options.php",$onlinelistname,3);
  writedata("$configarray[1]/$user/options.php",$showtimestamps,4);

  echo template('notice',array('notice'=>'User options updated!<br>Changes will be seen on next page you load'));
  echo "<br>";
  
 }else{

  $useroptarray=getdata("$configarray[1]/$user/options.php");

  $tplcontent['formheader'].="<form action=\"user_options.php\" method=post>";
  $tplcontent['formheader'].="<input type=hidden name=\"update\" value=\"1\">";
  $tplcontent['formheader'].="<input type=hidden name=\"user\" value=\"$user\">";
  $tplcontent['formheader'].="<input type=hidden name=\"mode\" value=\"edit\">";

  $tplcontent['pmautocheck'].="<tr>";
  $tplcontent['pmautocheck'].="<td class=\"tablecell1\" width=\"50%\">";
  $tplcontent['pmautocheck'].="<span class=\"textlarge\">Turn off auto check for private messages on every page</span><br>";
  $tplcontent['pmautocheck'].="</td><td class=\"tablecell2\" width=\"50%\">";
  if($useroptarray[0]=="on"){
  $tplcontent['pmautocheck'].="<input type=checkbox name=\"autocheckpms\" class=\"forminput\" checked>";
  }else{
  $tplcontent['pmautocheck'].="<input type=checkbox name=\"autocheckpms\" class=\"forminput\">";
  }
  $tplcontent['pmautocheck'].="</td>";
  $tplcontent['pmautocheck'].="</tr>";

  $tplcontent['iconguide'].="<tr>";
  $tplcontent['iconguide'].="<td class=\"tablecell1\">";
  $tplcontent['iconguide'].="<span class=\"textlarge\">Turn off forum/thread icon guide on bottom of pages</span><br>";
  $tplcontent['iconguide'].="</td><td class=\"tablecell2\">";
  if($useroptarray[1]=="on"){
  $tplcontent['iconguide'].="<input type=checkbox name=\"turnofficonguide\" class=\"forminput\" checked>";
  }else{
  $tplcontent['iconguide'].="<input type=checkbox name=\"turnofficonguide\" class=\"forminput\">";
  }
  $tplcontent['iconguide'].="</td>";
  $tplcontent['iconguide'].="</tr>";
  
  $tplcontent['poststats'].="<tr>";
  $tplcontent['poststats'].="<td class=\"tablecell1\">";
  $tplcontent['poststats'].="<span class=\"textlarge\">Turn off post stats on footer to increase speed of page loads</span><br>";
  $tplcontent['poststats'].="</td><td class=\"tablecell2\">";
  if($useroptarray[2]=="on"){
  $tplcontent['poststats'].="<input type=checkbox name=\"turnoffpoststats\" class=\"forminput\" checked>";
  }else{
  $tplcontent['poststats'].="<input type=checkbox name=\"turnoffpoststats\" class=\"forminput\">";
  }
  $tplcontent['poststats'].="</td>";
  $tplcontent['poststats'].="</tr>";
  
  $tplcontent['listinvisible'].="<tr>";
  $tplcontent['listinvisible'].="<td class=\"tablecell1\">";
  $tplcontent['listinvisible'].="<span class=\"textlarge\">Don't show your name in online list (invisible mode)</span><br>";
  $tplcontent['listinvisible'].="</td><td class=\"tablecell2\">";
  if($useroptarray[3]=="on"){
  $tplcontent['listinvisible'].="<input type=checkbox name=\"onlinelistname\" class=\"forminput\" checked>";
  }else{
  $tplcontent['listinvisible'].="<input type=checkbox name=\"onlinelistname\" class=\"forminput\">";
  }
  $tplcontent['listinvisible'].="</td>";
  $tplcontent['listinvisible'].="</tr>";
  
  if($useroptarray[4]=="on"){
  	$tplcontent['showtimestamps'].="<input type=checkbox name=\"showtimestamps\" class=\"forminput\" checked>";
  }else{
  	$tplcontent['showtimestamps'].="<input type=checkbox name=\"showtimestamps\" class=\"forminput\">";
  }
  
  $tplcontent['submitbutton'].="<input type=submit name=\"submit\" value=\"Update!\" class=\"formbutton\">";
  $tplcontent['formfooter'].="</form>";
  
  echo template('useroptions',$tplcontent);

 }//update check

}//access check

}

require ("footer.php");
?>
